<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>RF22: RF22Datagram Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">RF22
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">RF22Datagram Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="RF22Datagram" --><!-- doxytag: inherits="RF22" -->
<p><a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> subclass for addressed, unreliable messages.  
 <a href="classRF22Datagram.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="RF22Datagram_8h_source.html">RF22Datagram.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RF22Datagram:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classRF22Datagram.png" usemap="#RF22Datagram_map" alt=""/>
  <map id="RF22Datagram_map" name="RF22Datagram_map">
<area href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams." alt="RF22" shape="rect" coords="0,0,141,24"/>
<area href="classRF22ReliableDatagram.html" title="RF22 subclass for sending addressed, acknowledged, retransmitted datagrams." alt="RF22ReliableDatagram" shape="rect" coords="0,112,141,136"/>
<area href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw..." alt="RF22Router" shape="rect" coords="0,168,141,192"/>
<area href="classRF22Mesh.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw..." alt="RF22Mesh" shape="rect" coords="0,224,141,248"/>
</map>
 </div></div>

<p><a href="classRF22Datagram-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Datagram.html#a284ef536b2abcccff721e08ad53d103a">RF22Datagram</a> (uint8_t thisAddress=0, uint8_t slaveSelectPin=10, uint8_t interrupt=0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Datagram.html#a7e9eb654f8e8be094c5f2c0531218531">init</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Datagram.html#ab230f3306fa4fdeb218ac34b728cb3d2">setThisAddress</a> (uint8_t thisAddress)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Datagram.html#a316535aeb1cb389b593df5f8f1f38983">sendto</a> (uint8_t *buf, uint8_t len, uint8_t address)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Datagram.html#ab545144cb8529f5b5ef0dcb77a252eef">recvfrom</a> (uint8_t *buf, uint8_t *len, uint8_t *from=NULL, uint8_t *to=NULL, uint8_t *id=NULL, uint8_t *flags=NULL)</td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a831ccec7d05b864cc3618f9c21894f17"></a><!-- doxytag: member="RF22Datagram::_thisAddress" ref="a831ccec7d05b864cc3618f9c21894f17" args="" -->
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">_thisAddress</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The address of this node. Defaults to 0. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> subclass for addressed, unreliable messages. </p>
<p>Extends <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> to define addressed, unreliable datagrams. Every node has an 8 bit address (defaults to 0). Addresses (DEST and SRC) are 8 bit integers with an address of RF22_BROADCAST_ADDRESS (0xff) reserved for broadcast.</p>
<p>Part of the Arduino <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> library for operating with HopeRF <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> compatible transceivers (see <a href="http://www.hoperf.com">http://www.hoperf.com</a>). </p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a284ef536b2abcccff721e08ad53d103a"></a><!-- doxytag: member="RF22Datagram::RF22Datagram" ref="a284ef536b2abcccff721e08ad53d103a" args="(uint8_t thisAddress=0, uint8_t slaveSelectPin=10, uint8_t interrupt=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">RF22Datagram::RF22Datagram </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>thisAddress</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>slaveSelectPin</em> = <code>10</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>interrupt</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Constructor. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thisAddress</td><td>The address to assign to this node. Defaults to 0 </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">slaveSelectPin</td><td>the Arduino pin number of the output to use to select the <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> before accessing it </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">interrupt</td><td>The interrupt number to use. Default is interrupt 0 (Arduino input pin 2) </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">_thisAddress</a>.</p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a7e9eb654f8e8be094c5f2c0531218531"></a><!-- doxytag: member="RF22Datagram::init" ref="a7e9eb654f8e8be094c5f2c0531218531" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Datagram::init </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initialises this instance and the radio module connected to it. Overrides the <a class="el" href="classRF22Datagram.html#a7e9eb654f8e8be094c5f2c0531218531">init()</a> function in <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> </p>

<p>Reimplemented from <a class="el" href="classRF22.html#ac211ed2b29be32088714b4bfa1ebbe4c">RF22</a>.</p>

<p>Reimplemented in <a class="el" href="classRF22Router.html#ac6037c3300511d0277e42edea8ccf873">RF22Router</a>.</p>

<p>References <a class="el" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">_thisAddress</a>, and <a class="el" href="classRF22Datagram.html#ab230f3306fa4fdeb218ac34b728cb3d2">setThisAddress()</a>.</p>

</div>
</div>
<a class="anchor" id="ab545144cb8529f5b5ef0dcb77a252eef"></a><!-- doxytag: member="RF22Datagram::recvfrom" ref="ab545144cb8529f5b5ef0dcb77a252eef" args="(uint8_t *buf, uint8_t *len, uint8_t *from=NULL, uint8_t *to=NULL, uint8_t *id=NULL, uint8_t *flags=NULL)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Datagram::recvfrom </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>from</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>to</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>id</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>flags</em> = <code>NULL</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Turns the receiver on if it not already on. If there is a valid message available for this node, copy it to buf and return true The SRC address is placed in *from if present and not NULL. The DEST address is placed in *to if present and not NULL. If a message is copied, *len is set to the length. You should be sure to call this function frequently enough to not miss any messages It is recommended that you call it in your main loop. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Location to copy the received message </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">len</td><td>Pointer to available space in buf. Set to the actual number of octets copied. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">from</td><td>If present and not NULL, the referenced uint8_t will be set to the FROM address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">to</td><td>If present and not NULL, the referenced uint8_t will be set to the TO address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">id</td><td>If present and not NULL, the referenced uint8_t will be set to the ID </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">flags</td><td>If present and not NULL, the referenced uint8_t will be set to the FLAGS (not just those addressed to this node). </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if a valid message was copied to buf </dd></dl>

<p>References <a class="el" href="classRF22.html#a3ecbb26863c8bd4bf8cbacde37b73d4f">RF22::headerFlags()</a>, <a class="el" href="classRF22.html#a3d8d98b524d14519f6c39d7136b5a422">RF22::headerFrom()</a>, <a class="el" href="classRF22.html#a74b21003336cc7c6aac1dad128b1f205">RF22::headerId()</a>, <a class="el" href="classRF22.html#ad61bb70ba171a81fa8803219fdc2a433">RF22::headerTo()</a>, and <a class="el" href="classRF22.html#a2f6f295a313e1ebf244b91338ed22f13">RF22::recv()</a>.</p>

<p>Referenced by <a class="el" href="classRF22ReliableDatagram.html#a49dbf986b90cac7f1476ec56a4beab38">RF22ReliableDatagram::recvfromAck()</a>.</p>

</div>
</div>
<a class="anchor" id="a316535aeb1cb389b593df5f8f1f38983"></a><!-- doxytag: member="RF22Datagram::sendto" ref="a316535aeb1cb389b593df5f8f1f38983" args="(uint8_t *buf, uint8_t len, uint8_t address)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Datagram::sendto </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>address</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sends a message to the node(s) with the given address RF22_BROADCAST_ADDRESS is a valid address which will cause the message to be accepted by all <a class="el" href="classRF22Datagram.html" title="RF22 subclass for addressed, unreliable messages.">RF22Datagram</a> nodes within range. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Pointer to the binary message to send </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">len</td><td>Number of octets to send </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The address to send the message to. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the message was transmitted. </dd></dl>

<p>References <a class="el" href="classRF22.html#a217941f83c9f645350cf7d5d16d8cc3d">RF22::send()</a>, and <a class="el" href="classRF22.html#ac45b0f89bb116d546cc5e90410173827">RF22::setHeaderTo()</a>.</p>

<p>Referenced by <a class="el" href="classRF22ReliableDatagram.html#aec55325c6ab74809a3ef9c90aef39adc">RF22ReliableDatagram::acknowledge()</a>, and <a class="el" href="classRF22ReliableDatagram.html#a47e85bffb81a3acdff6d5f15ce7bb65e">RF22ReliableDatagram::sendtoWait()</a>.</p>

</div>
</div>
<a class="anchor" id="ab230f3306fa4fdeb218ac34b728cb3d2"></a><!-- doxytag: member="RF22Datagram::setThisAddress" ref="ab230f3306fa4fdeb218ac34b728cb3d2" args="(uint8_t thisAddress)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Datagram::setThisAddress </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>thisAddress</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sets the address of this node. Defaults to 0. This will be used to set the FROM address of all messages sent by this node. If all the nodes leave the address unset (ie 0), In a conventional multinode system, all nodes will have a unique address (which you could store in EEPROM). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thisAddress</td><td>The address of this node </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">_thisAddress</a>, <a class="el" href="classRF22.html#af446e330a074e528253f3c7706b14b09">RF22::setHeaderFrom()</a>, and <a class="el" href="classRF22.html#a02bb8ac61e753e0354b87be423adf2e4">RF22::spiWrite()</a>.</p>

<p>Referenced by <a class="el" href="classRF22Datagram.html#a7e9eb654f8e8be094c5f2c0531218531">init()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="RF22Datagram_8h_source.html">RF22Datagram.h</a></li>
<li>RF22Datagram.cpp</li>
</ul>
</div>


<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
